function showPhoneyPlateVehicleSearch(){
	window.location.href="showPhoneyPlateVehicleSearch.do";
}

function ajaxFindPhoneyPlateVehicleSearchList(currentPage,pageSize) {
	$.ajax({
		type:"post",
		url: "ajaxPhoneyPlateVehicleSearchList.do",
		data:{
			plateNum:$("#plateNum").val(),	
			plateTypeId:$("#licencePlateKind").val(),		
			vehicleTypeId:$("#vehicleType").val(),
			usingCharacterId:$("#useNature").val(),
			vehicleClassificationId:$("#vehicleClassification").val(),
			currentPage:currentPage,
			pageSize:pageSize,
			orderBy:"id",
		},
		success:function(msg){
			$("#listPhoneyPlateVehicleBox").html(msg);
		}
	});
}

function ajaxShowPhoneyPlateVehicleEdit(id){
	$.ajax({
		type:"post",
		url:"ajaxShowPhoneyPlateVehicleEdit.do",
		data:{phoneyPlateVehicleId:id},
		success:function(msg){
			$("#dialog").html(msg);
			$("#dialog").dialog({
				autoOpen: true,
				width: 800,
				title:$(".dialogtitle").attr("title"),
				modal: true,
				buttons: [
				          {
				        	  text: "保存",
				        	  click: function() {
				        		  ajaxSavePhoneyPlateVehicle(this);
				        	  }
				          },
				          {
				        	  text: "关闭",
				        	  click: function() {
				        		  $(this).dialog( "close" );
				        	  }
				          }
				          ]
			});
		}
	});
}

function ajaxSavePhoneyPlateVehicle(objDialog) {
	phoneyPlateVehicleValidate();
	if ($("#frmPhoneyPlateVehicle").valid()) {
		$(objDialog).dialog("close");
		var options ={
				type: "post",
				url : "ajaxSavePhoneyPlateVehicle.do",
				success: function (msg) {
					clearInput("#sltPhoneyPlate");
					ajaxFindPhoneyPlateVehicleSearchList();
					showMessageDialog("保存假牌车","假牌车信息保存成功。",null,dialogType.info);
				}
		};
		$("#frmPhoneyPlateVehicle").ajaxSubmit(options);
	}
}

function ajaxShowPhoneyPlateVehicleView(id){
	$.ajax({
		type:"post",
		url:"ajaxShowPhoneyPlateVehicleView.do",
		data:{phoneyPlateVehicleId:id},
		success:function(msg){
			$("#dialog").html(msg);
			$("#dialog").dialog({
				autoOpen: true,
				width: 800,
				title:$(".dialogtitle").attr("title"),
				modal: true,
				buttons: [
				          {
				        	  text: "关闭",
				        	  click: function() {
				        		  $(this).dialog( "close" );
				        	  }
				          }
				          ]
			});
		}
	});
}

function ajaxDeletePhoneyPlateVehicleById(id) {
	var phoneyPlateVehicleIds="";
	var sltPPV = $("#listPhoneyPlateVehicleList tbody input:checked").length;
	if(id==null){
		$("#listPhoneyPlateVehicleList tbody input:checked").each(function() {
			phoneyPlateVehicleIds += $(this).val()+";";
		});
		if (sltPPV == 0) {
			showMessageDialog("提示","请选择一行或多行",null,dialogType.info);
			return;
		} else{
			phoneyPlateVehicleIds=phoneyPlateVehicleIds.substring(0, phoneyPlateVehicleIds.length-1);
		}
	}else{
		phoneyPlateVehicleIds=id;
		sltPPV = 1;
	}
	if( phoneyPlateVehicleIds!=null) {
		showMessageDialog("删除假牌车","确定要删除所选“"+sltPPV+"”条假牌车记录吗？",
				function () {
			$.ajax({					
				type:"post",
				url:"ajaxDeletePhoneyPlateVehicleByIds.do",
				data:{phoneyPlateVehicleIds:phoneyPlateVehicleIds},
				success:function(msg){
					ajaxFindPhoneyPlateVehicleSearchList();
					showMessageDialog("提示","假牌车辆删除成功",null,dialogType.info);
				}
			});}
		,dialogType.warning);
	}
}

function phoneyPlateVehicleValidate(){
	$("#frmPhoneyPlateVehicle").validate({
		errorLabelContainer: $("#infoPhoneyPlateVehiclet"),
		rules : {
			plateNum : {
				required :true				
			},
			plateTypeId : {
				required :true				
			}
		},
		messages : {
			plateNum : {
				required :"请输入号牌号码！"
			},
			plateTypeId : {
				required :"请输入号牌种类！"
			}
		},
		success: function(label) {
			label.html("&nbsp;");
		}
	});
}